package com.ruoyi.ziran.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ziran.service.IZrQuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ziran.mapper.ZrPaperUserItemMapper;
import com.ruoyi.ziran.domain.ZrPaperUserItem;
import com.ruoyi.ziran.service.IZrPaperUserItemService;
import com.ruoyi.common.core.text.Convert;

/**
 * 用户答题详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@Service
public class ZrPaperUserItemServiceImpl implements IZrPaperUserItemService 
{
    @Autowired
    private ZrPaperUserItemMapper zrPaperUserItemMapper;
    @Autowired
    private IZrQuestionBankService iZrQuestionBankService;

    /**
     * 查询用户答题详情
     * 
     * @param id 用户答题详情主键
     * @return 用户答题详情
     */
    @Override
    public ZrPaperUserItem selectZrPaperUserItemById(Long id)
    {
        return zrPaperUserItemMapper.selectZrPaperUserItemById(id);
    }

    /**
     * 查询用户答题详情列表
     * 
     * @param zrPaperUserItem 用户答题详情
     * @return 用户答题详情
     */
    @Override
    public List<ZrPaperUserItem> selectZrPaperUserItemList(ZrPaperUserItem zrPaperUserItem)
    {
        List<ZrPaperUserItem> list=zrPaperUserItemMapper.selectZrPaperUserItemList(zrPaperUserItem);
        list.forEach(e->{
            e.setZrQuestionBank(iZrQuestionBankService.selectZrQuestionBankById(e.getQuestionBankId()));
        });
        return list;
    }

    /**
     * 新增用户答题详情
     * 
     * @param zrPaperUserItem 用户答题详情
     * @return 结果
     */
    @Override
    public int insertZrPaperUserItem(ZrPaperUserItem zrPaperUserItem)
    {
        zrPaperUserItem.setCreateTime(DateUtils.getNowDate());
        return zrPaperUserItemMapper.insertZrPaperUserItem(zrPaperUserItem);
    }

    /**
     * 修改用户答题详情
     * 
     * @param zrPaperUserItem 用户答题详情
     * @return 结果
     */
    @Override
    public int updateZrPaperUserItem(ZrPaperUserItem zrPaperUserItem)
    {
        zrPaperUserItem.setUpdateTime(DateUtils.getNowDate());
        return zrPaperUserItemMapper.updateZrPaperUserItem(zrPaperUserItem);
    }

    /**
     * 批量删除用户答题详情
     * 
     * @param ids 需要删除的用户答题详情主键
     * @return 结果
     */
    @Override
    public int deleteZrPaperUserItemByIds(String ids)
    {
        return zrPaperUserItemMapper.deleteZrPaperUserItemByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户答题详情信息
     * 
     * @param id 用户答题详情主键
     * @return 结果
     */
    @Override
    public int deleteZrPaperUserItemById(Long id)
    {
        return zrPaperUserItemMapper.deleteZrPaperUserItemById(id);
    }
}
